#include<iostream>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
using namespace std;
int g_val = 0;
int main()
{

    pid_t id = fork();
    if(id == 0) {
        cout << "child process" << endl;
        cout << "pid: " << getpid() << endl;
        cout << "ppid: " << getppid() << endl;
        cout << "id: " << id << endl;
        cout<<"&g_val: "<<&g_val<<endl;
        g_val = 1;
        cout<<"change g_val: "<<g_val<<endl;
    } else {
        cout << "parent process" << endl;
        cout << "pid: " << getpid() << endl;
        cout << "ppid: " << getppid() << endl;
        cout << "id: " << id << endl;
        cout<<"&g_val: "<<&g_val<<endl;
    }

    return 0;
}